 <template>
   <div>
   <div class="box">
     <i style="margin:0 10px" class="el-icon-info"></i>
     <span>数据一共{{countlength}}条</span>
    </div>
  <el-table
    :data="tableData"
    border
    style="width: 100%">
    <el-table-column
      fixed
      prop="number"
      label="试题编号"
      width="200">
    </el-table-column>
    <el-table-column
      prop="subject"
      label="学科"
      width="120">
    </el-table-column>
    <el-table-column
      prop="catalog"
      label="目录"
      width="120">
    </el-table-column>
    <el-table-column
      prop="questionType"
      label="题型"
      width="120">
      <template v-slot="{row}">
       {{row.questionType | questionType}}
      </template>
    </el-table-column>
    <el-table-column
      prop="question"
      label="题干"
      width="200">
     <template v-slot="{row}">
       {{row.question | html2Text}}
      </template>
    </el-table-column>
    <el-table-column
      prop="zip"
      label="录入时间"
      width="150">
    <template v-slot="{row}">
       {{row.addDate | parseTimeByString}}
      </template>
    </el-table-column>
        <el-table-column
      prop="zip"
      label="难度"
      width="80">
    <template v-slot="{row}">
       {{row.difficulty | updatedifficulty}}
      </template>
    </el-table-column>
        <el-table-column
      prop="zip"
      label="录入人"
      width="150">
    <template v-slot="{row}">
       {{row.chkUser }}
      </template>
    </el-table-column>
        <el-table-column
      prop="zip"
      label="审核状态"
      width="150">
      <template v-slot="{row}">
       {{row. chkState|chkStatechange}}
      </template>
    </el-table-column>
        <el-table-column
      prop="chkRemarks"
      label="审核意见"
      width="150">
    </el-table-column>
    <el-table-column
      prop="chkUser"
      label="审核人"
      width="120">
    </el-table-column>
        <el-table-column
      prop="zip"
      label="发布状态"
      width="120">
      <template v-slot="{row}">
      {{row|publishType}}
      </template>
    </el-table-column>
    <el-table-column
      fixed="right"
      label="操作"
      width="200">
      <template slot-scope="scope">
        <el-button @click="onchangelogin(scope.row)" type="text" size="small" >预览</el-button>
        <el-button :disabled='scope.row.chkState===1||scope.row.chkState===2' @click="tochstate(scope.row)"    type="text" size="small">审核</el-button>
        <el-button @click="$router.push('new/?id='+scope.row.id)" :disabled='scope.row.publishState===1' type="text" size="small">修改</el-button>
        <el-button @click="topublishState(scope.row)" type="text" size="small">{{scope.row.publishState===1?'下架':'上架'}}</el-button>
        <el-button :disabled='scope.row.publishState===1' type="text" size="small" @click="ondelete(scope.row)">删除</el-button>
      </template>
    </el-table-column>

  </el-table>

</div>
  </template>

<script>

export default {
  props: {
    tableData: {
      type: Array,
      required: true
    },
    countlength: {
      type: Number,
      required: true
    }
  },
  data () {
    return {
      dialogVisible: false
    }
  },

  created () {

  },

  methods: {
    ondelete (row) {
      this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        try {
          this.$emit('todelete', row)
          this.$message({
            type: 'success',
            message: '删除成功!'
          })
        } catch (err) {
          console.log(err)
        }
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    onchangelogin (row) {
      this.$emit('tochangelogin', row)
    },
    topublishState (row) {
      this.$emit('topublishState', row)
    },
    tochstate (row) {
      this.$emit('tochstate', row)
    }

  }
}
</script>

<style scoped lang='less'>
div{
  display: block;
  width: 100%;
  background-color: #f4f4f5;

}
.box{
    height: 35px;
  line-height: 35px;
  color: #909399;
}
</style>
